package com.cq.hd.admin.controller;

import com.cq.hd.admin.annotation.RequiresPermissionsDesc;
import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.member.api.TbBusinessEnterApplyApi;
import com.cq.hd.member.api.dto.BusinessEnterApplyPageDto;
import com.cq.hd.member.api.dto.BusinessEnterAuditDto;
import com.cq.hd.member.api.dto.MerchantOpenDto;
import com.cq.hd.member.api.dto.MerchantSubAcctOpenDto;
import com.cq.hd.member.api.vo.BusinessEnterApplyPageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 商家入驻申请记录表 前端控制器
 * </p>
 *
 * @author mYunYu
 * @since 2023-11-21
 */
@Api(tags = "商家入驻审核相关接口")
@Slf4j
@RestController
@RequestMapping("/businessEnterApply")
public class TbBusinessEnterApplyController {

    private TbBusinessEnterApplyApi businessEnterApplyApi;

    @Autowired
    public void setBusinessEnterApplyApi(TbBusinessEnterApplyApi businessEnterApplyApi) {
        this.businessEnterApplyApi = businessEnterApplyApi;
    }

    @ApiOperation(value = "商家入驻申请列表")
    @ApiImplicitParam(name = "businessEnterApplyPageDto", value = "实体", paramType = "query", dataType = "BusinessEnterApplyPageDto")
    @ApiResponse(response = BusinessEnterApplyPageVo.class, code = 200, message = "接口返回对象参数")
    @RequiresPermissions("business:businessEnterApply:list")
    @RequiresPermissionsDesc(menu = {"商家入驻审核管理", "商家入驻审核管理"}, button = "查询")
    @GetMapping("/page")
    public Result<Page<BusinessEnterApplyPageVo>> pageBusinessEnterApply(BusinessEnterApplyPageDto businessEnterApplyPageDto) {
        return businessEnterApplyApi.pageBusinessEnterApply(businessEnterApplyPageDto);
    }

    @ApiOperation(value = "商家入驻申请详情")
    @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query", dataType = "Long")
    @ApiResponse(response = BusinessEnterApplyPageVo.class, code = 200, message = "接口返回对象参数")
    @RequiresPermissions("business:businessEnterApply:details")
    @RequiresPermissionsDesc(menu = {"商家入驻审核管理", "商家入驻审核管理"}, button = "详情")
    @GetMapping("/details")
    public Result<BusinessEnterApplyPageVo> details(Long id) {
        return businessEnterApplyApi.details(id);
    }

    @ApiOperation(value = "商家入驻申请审核")
    @ApiImplicitParam(name = "businessEnterAuditDto", value = "实体", paramType = "body", dataType = "BusinessEnterAuditDto")
    @RequiresPermissions("business:businessEnterApply:audit")
    @RequiresPermissionsDesc(menu = {"商家入驻审核管理", "商家入驻审核管理"}, button = "审核")
    @PostMapping("/audit")
    public Result<Boolean> audit(@RequestBody BusinessEnterAuditDto businessEnterAuditDto) {
        return businessEnterApplyApi.audit(businessEnterAuditDto);
    }

    @ApiOperation(value = "手动开通商户业务")
    @ApiImplicitParam(name = "merchantOpenDto", value = "实体", paramType = "body", dataType = "MerchantOpenDto")
    @RequiresPermissions("business:businessEnterApply:merchantOpen")
    @RequiresPermissionsDesc(menu = {"商家入驻审核管理", "商家入驻审核管理"}, button = "手动开通商户业务")
    @PostMapping("/merchantOpen")
    public Result<Boolean> merchantOpen(@RequestBody MerchantOpenDto merchantOpenDto) {
        return businessEnterApplyApi.merchantOpen(merchantOpenDto);
    }

    @ApiOperation(value = "手动开通子账号")
    @ApiImplicitParam(name = "merchantSubAcctOpenDto", value = "实体", paramType = "body", dataType = "MerchantSubAcctOpenDto")
    @RequiresPermissions("business:businessEnterApply:merchantSubAcctOpen")
    @RequiresPermissionsDesc(menu = {"商家入驻审核管理", "商家入驻审核管理"}, button = "手动开通子账号")
    @PostMapping("/merchantSubAcctOpen")
    public Result<Boolean> merchantSubAcctOpen(@RequestBody MerchantSubAcctOpenDto merchantSubAcctOpenDto) {
        return businessEnterApplyApi.merchantSubAcctOpen(merchantSubAcctOpenDto);
    }


}
